package com.wangxiaotao.springcloud.controller;

import com.wangxiaotao.springcloud.entities.CommonResult;
import com.wangxiaotao.springcloud.entities.Payment;
import com.wangxiaotao.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * feign 直接调用service实现服务调用
 * @author Wangxiaotao
 * @create 2021-09-08-23:26
 */
@RestController
@Slf4j
public class OrderFeignCpntrollrt {

    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/comsumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id")Long id){
        return paymentFeignService.getPaymentById(id);
    }

    @GetMapping(value = "/comsumer/payment/feign/timeout")
    public String payemntFeignTimeOut(){
        //openfeign-ribbon 客户端默认等待1s
        return paymentFeignService.payemntFeignTimeOut();
    }
}
